<!DOCTYPE html>
<!-- Copyright © 2021~2022 by wzh -->
<html lang="zh">
	<head>
		<meta charset="UTF-8" />
		<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
		<title>五子棋</title>
		
		<!--icon-->
		<link href="./img/icon.png" rel="icon" type="image/x-icon"/>
		
		<!-- 异步fonts加载 -->
		<script src="./js/webfontloader.js"></script>
		<script>
		if (typeof require != "undefined"){ //electron
			console.log("electron")
			document.write(`<link href="./css/fonts.css" rel="stylesheet" type="text/css" />`);
			window.onload = function(){
				console.log("onload")
				$("body").addClass("wf-active");
			}
		}else{
			WebFont.load({
				google: {
					families: ["kt", "st", "xs", "zyyt"],
					api: "./css/fonts.css"
				}
			});
		}
		</script>
		
		<style>
		/* 字体缩放方案 */
		/* @media screen and (max-width:320px){
			body {font-size: calc(0.018 * 320px + 6px) !important;}
		}
		body{
			font-size: calc(1.8vw + 6px) !important;
		}
		@media screen and (min-width: 960px){
			body {font-size: calc(0.018 * 960px + 6px) !important;}
		} */
		
		/* layui */
		.layui-btn-group .layui-btn:not(:first-child){
			border-left-style: none !important;
		}
		
		/* daovoice */
		.daodream-container.daodream-reset{
			position: absolute;
		}
		
		/* element */
		*{
			outline: none; /* 无点击线 */
		}
		html{
			/* 禁止选择 */
			-moz-user-select: none;
			-khtml-user-select: none;
			user-select: none;
			
			/* 背景 */
			min-height: 100%;
			background: #fffae8 url("./img/background.jpg") no-repeat fixed center;
			background-size: cover;
			max-width: 100%;
			margin: auto;
		}
		html.outUp{
			background-image: none;
			background-color: #fffae8;
		}
		
		/* 初始页 */
		body{
			position: absolute;
			width: 100%;
			height: 100%;
			left: 0;
			top: 0;
			margin: 0;
			
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			
			/* 背景 */
			min-height: 100%;
			background: #1b2036 url("./img/background.jpg") no-repeat fixed center;
			background-size: cover;
			max-width: 100%;
			margin: auto;
			
			opacity: 0; /* 完全透明 */
			transition: top 0.6s, opacity 0.6s; /* 出入动画 */
		}
		html.fadeIn > body{
			opacity: 1; /* 不透明 */
		}
		html.outUp > body{
			top: -100%; /* 上滑 */
		}
		
		/* h1 */
		body > h1{
			margin: 0;
			font-size: 3.6em;
			text-align: center;
			font-weight: bold;
			color: white;
		}
		
		/* set */
		#set{
			position: absolute;
			left: 0;
			top: 0;
			display: flex;
			flex-direction: column;
		}
		#set > i{
			display: block;
			font-size: 3.6em;
		}
		#set > label{
			display: block;
			margin: 0 auto;
			margin-top: -5px;
			font-size: 1.1em;
			font-weight: bold;
		}
		
		
		/* 打开战绩 */
		#openRecord{
			position: absolute;
			right: 0;
			top: 0;
			display: flex;
			flex-direction: column;
		}
		#openRecord > i{
			display: block;
			font-size: 3.6em;
		}
		#openRecord > label{
			display: block;
			margin: 0 auto;
			margin-top: -5px;
			font-size: 1.1em;
			font-weight: bold;
		}
		
		/* button */
		body > button{
			width: 66vw;
			margin: 0 auto;
			padding: 0.5rem;
			font-size: 2em;
			
			color: #6af;
			background-color: #fff;
			border: 3px outset #6af;
			border-radius: 0.3rem;
			transition: color 0.3s, background-color 0.3s;
		}
		body > button:hover{
			color: #fff;
			background-color: #6af;
		}
		body > button:active{
			background-color: #59e;
			border: 3px inset #6af;
		}
		
		
		/* 设置 */
		#settings{
			position: absolute;
			width: 100%;
			height: 100%;
			left: 0;
			top: 0;
			margin: 0;
			padding: 0;
			overflow-y: auto;
			
			background-color: #fafafa;
			font-size: 1.3em;
		}
		
		/* h2 */
		#settings > h2{
			margin: 1rem;
			font-size: 2em;
			font-weight: bold;
			text-align: center;
		}
		
		/* form表单 */
		#settings .layui-tab-title{
			overflow-x: auto;
			overflow-y: hidden;
		}
		#settings form{
			padding-right: 0.6rem;
		}
		#settings form label{
			word-break: break-word;
			text-overflow: clip;
		}
		/*#settings > form > div{
			margin: 1rem;
			display: flex;
		}
		#settings > form > div > *{
			margin: 0.2rem;
		}
		#settings > form > div > input[type="range"]{
			width: 25vw;
		}
		#settings > form > div > label,
		#settings > form > div > input[type="range"]{
			flex: none;
		}
		#settings > form > div > input[type="number"],
		#settings > form > div > button{
			width: 100%;
		}*/
		
		/* button */
		#settings > div.btn{
			display: flex;
		}
		#settings > div.btn > button{
			width: 100%;
			margin: 0.3rem;
			padding: 0.3rem;
			font-size: 1.2em;
			
			transition: color 0.3s, background-color 0.3s;
		}
		#settings > div.btn > button.save{
			color: #fff;
			background-color: #6af;
			border: 3px outset #6af;
			border-radius: 0.3rem;
		}
		/*#settings > div.btn > button.save:hover{
			color: #fff;
			background-color: #6af;
		}*/
		#settings > div.btn > button.save:active{
			background-color: #59e;
			border: 3px inset #6af;
		}
		
		#settings > div.btn > button.cancel{
			color: #ea6;
			background-color: #fff;
			border: 3px outset #ea6;
			border-radius: 0.3rem;
		}
		#settings > div.btn > button.cancel:hover{
			color: #fff;
			background-color: #ea6;
		}
		#settings > div.btn > button.cancel:active{
			background-color: #d95;
			border: 3px inset #ea6;
		}
		
		
		/* 战绩 */
		#record{
			position: absolute;
			width: 100%;
			height: 100%;
			left: 0;
			top: 0;
			margin: 0;
			padding: 0;
			overflow-y: auto;
			
			background-color: #fafafa;
			font-size: 1.3em;
		}
		
		/* h2 */
		#record > h2{
			margin: 1rem;
			font-size: 2em;
			font-weight: bold;
			text-align: center;
		}
		
		/* h3 */
		#record > h3{
			margin: 0.6rem;
			font-size: 1.2em;
			/*font-weight: bold;*/
		}
		
		/* table */
		#record > table{
			margin: 0.6rem;
			margin-bottom: 2rem;
			text-align: center;
		}
		#record > table th, #record > table td{
			padding: 0.2rem;
		}
		
		/* button */
		#record > .back{
			position: absolute;
			left: 50%;
			transform: translateX(-50%);
			width: 66%;
			margin: 0.3rem auto;
			padding: 0.3rem;
			
			color: #fff;
			background-color: #6af;
			border: 3px outset #6af;
			border-radius: 0.3rem;
			font-size: 1.2em;
			transition: color 0.3s, background-color 0.3s;
		}
		#record > .back:active{
			background-color: #59e;
			border: 3px inset #6af;
		}
		</style>
		
		<!-- jquery -->
		<script src="./js/jquery.min.js"></script>
		<script>
		if (typeof require != "undefined") //electron
			window.$ = window.jQuery = require("./js/jquery.min.js");
		</script>
		
		<!-- 语言包 -->
		<script src="./lang/lang.js"></script>
		
		<!-- layui -->
		<!--<link rel="stylesheet" href="https://unpkg.com/layui@2.6.4/dist/css/layui.css">
		<script src="https://unpkg.com/layui@2.6.8/dist/layui.js"></script>-->
		<script src="./layui/layui.js"></script>
		<link rel="stylesheet" href="./layui/css/layui.css" />
		
		<!-- 调试工具 -->
		<!-- <script src="https://cdn.jsdelivr.net/npm/eruda"></script>
		<script src="https://cdn.bootcss.com/vConsole/3.3.4/vconsole.min.js"></script>
		<script>
		if ( /ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/.test( navigator.userAgent.toLowerCase() ) ){
			//手机
			eruda.init();
			new VConsole();
		}
		</script> -->
		
		<script src="./js/js_plus.min.js"></script> <!-- js+ -->
		
		<!-- PianoMusic Bgm -->
		<script src="./js/acoustic_grand_piano-ogg.js"></script>
		<script src="./js/music.js"></script>
		<script src="./js/bgm.js"></script>
		
		<script src="https://wzh656.github.io/gobang/js/dynamic.js" async></script>
		<script src="https://wzh656.github.io/gobang/js/count.js" async></script>
		<script>
		var _hmt = _hmt || [];
		(function() {
			var hm = document.createElement("script");
			hm.src = "https://hm.baidu.com/hm.js?c6b8f0ad7ec671e54d83e86a67280999";
			var s = document.getElementsByTagName("script")[0]; 
			s.parentNode.insertBefore(hm, s);
		})();
		</script>
		
		<!-- Global site tag (gtag.js) - Google Analytics -->
		<script async src="https://www.googletagmanager.com/gtag/js?id=G-WTWJEHK1C2"></script>
		<script>
		window.dataLayer = window.dataLayer || [];
		function gtag(){dataLayer.push(arguments);}
		gtag('js', new Date());
		
		gtag('config', 'G-WTWJEHK1C2');
		</script>
		
		<!--<script>
		(function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/c17090af.js","daovoice")
		daovoice('init', {
		  app_id: "c17090af"
		});
		daovoice('update');
		</script>-->
		
	</head>
	<body>
		<h1>五子棋</h1>
		<div id="set">
			<i class="layui-icon layui-icon-set-fill"></i>
			<label>设置</label>
		</div>
		<div id="openRecord">
			<i class="layui-icon layui-icon-chart-screen"></i>
			<label>战绩</label>
		</div>
		<button id="two">两个人</button>
		<button id="one">一个人</button>
		<button id="online">很多人</button>
		<button id="tutorial">玩法教程</button>
		<section id="settings" style="display: none;">
			<h2>设置</h2>
			<div class="layui-tab layui-tab-brief">
				<ul class="layui-tab-title">
					<li class="game layui-this">游戏设置</li>
					<li class="personal">个性化设置</li>
					<li class="music">音乐设置</li>
					<li class="language">语言设置(Language)</li>
				</ul>
				<div class="layui-tab-content">
					<form class="game layui-tab-item layui-show layui-form" onsubmit="return false;">
						<div class="layui-form-item">
							<label class="layui-form-label">维数</label>
							<div class="layui-input-inline layui-btn-group">
								<button class="two layui-btn">2D</button>
								<button class="three layui-btn layui-btn-primary layui-border-green">3D</button>
								<button class="four layui-btn layui-btn-primary layui-border-green">4D</button>
							</div>
							<div class="text layui-form-mid layui-word-aux">2D：回归传统，品味经典游戏</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">连子数</label>
							<div class="layui-input-inline">
								<input type="number" name="n" min="3" max="19" value="5" class="layui-input" />
							</div>
							<div class="layui-form-mid layui-word-aux">指获胜需要的连续棋子数</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">棋盘行数</label>
							<div class="layui-input-inline">
								<input type="number" name="rows" min="1" max="30" init="19" value="19" class="layui-input" />
							</div>
							<div class="layui-form-mid layui-word-aux">单位：棋子个数</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">棋盘列数</label>
							<div class="layui-input-inline">
								<input type="number" name="cols" min="1" max="30" init="19" value="19" class="layui-input" />
							</div>
							<div class="layui-form-mid layui-word-aux">单位：棋子个数</div>
						</div>
						<div class="layui-form-item" style="display: none;">
							<label class="layui-form-label">棋盘深度</label>
							<div class="layui-input-inline">
								<input type="number" name="depth" min="1" max="30" init="10" value="10" class="layui-input" />
							</div>
							<div class="layui-form-mid layui-word-aux">单位：棋子个数</div>
						</div>
						<div class="layui-form-item" style="display: none;">
							<label class="layui-form-label">四维厚度</label>
							<div class="layui-input-inline">
								<input type="number" name="width" min="1" max="30" init="10" value="10" class="layui-input" />
							</div>
							<div class="layui-form-mid layui-word-aux">单位：棋子个数</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">局时</label>
							<div class="layui-input-inline">
								<input type="number" name="totalTime" min="60" max="Infinity" init="300" value="300" class="layui-input" />
							</div>
							<div class="layui-form-mid layui-word-aux">单位：秒(s)</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">步时</label>
							<div class="layui-input-inline">
								<input type="number" name="stepTime" min="5" max="Infinity" init="30" value="30" class="layui-input" />
							</div>
							<div class="layui-form-mid layui-word-aux">单位：秒(s)</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">下棋位置</label>
							<div class="layui-input-inline">
								<input type="radio" name="place" title="格点" checked />
								<input type="radio" name="place" title="格内" />
							</div>
							<div class="layui-form-mid layui-word-aux">指在线的交点处 或围成的方格内落子</div>
						</div>
					</form>
					<form class="personal layui-tab-item layui-form" onsubmit="return false;">
						<div class="layui-form-item">
							<label class="layui-form-label">防误触摸式</label>
							<div class="layui-input-inline">
								<input type="checkbox" name="mistake" class="mistake" lay-skin="switch" lay-text="开启|关闭" />
							</div>
							<div class="layui-form-mid layui-word-aux">即是否需要两次点击落子以防止误触</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">天空盒</label>
							<div class="layui-input-inline">
								<input type="checkbox" name="skybox" class="skybox" lay-skin="switch" lay-text="显示|关闭" lay-filter="skybox" />
							</div>
							<div class="layui-form-mid layui-word-aux">（针对3D/4D五子棋）开启后将可边下棋边在白天欣赏每天720次的日出日落</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">月亮</label>
							<div class="layui-input-inline">
								<input type="checkbox" name="moon" class="moon" lay-skin="switch" lay-text="显示|关闭" />
							</div>
							<div class="layui-form-mid layui-word-aux">（针对3D/4D五子棋）开启后将可边下棋边在夜里欣赏作者自摄的月亮</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">棋盘边界</label>
							<div class="layui-input-inline">
								<input type="checkbox" name="border" class="border" lay-skin="switch" lay-text="显示|关闭" />
							</div>
							<div class="layui-form-mid layui-word-aux">（针对3D/4D五子棋）开启后将在棋盘边界显示立方体边框，以标注提醒</div>
						</div>
					</form>
					<form class="music layui-tab-item layui-form" onsubmit="return false;">
						<div class="layui-form-item">
							<label class="layui-form-label">背景音乐</label>
							<div class="layui-input-block">
								<select name="bgm" lay-filter="bgm">
									<option value="none">无</option>
									<option value="piano" checked>纯音乐钢琴曲(deskgood作曲)</option>
									<option value="piano2">纯音乐钢琴曲2</option>
									<option value="youth">无题（纯音乐未作词）by Louise</option>
									<option value="LonelyWarrior">孤勇者</option>
									<option value="random">网抑云随机热歌</option>
									<option value="local">本地音频</option>
									<option value="custom">自定义</option>
								</select>
							</div>
						</div>
						<div class="layui-form-item layui-form-text" style="display: none;">
							<label class="layui-form-label">本地音频</label>
							<div class="layui-input-block">
								<input name="bgm_local" type="file" class="layui-input"></input>
							</div>
						</div>
						<div class="layui-form-item layui-form-text" style="display: none;">
							<label class="layui-form-label">bgm乐谱</label>
							<div class="layui-input-block">
								<textarea name="bgm_custom" rows="10" placeholder="请输入乐谱" class="layui-textarea"></textarea>
							</div>
						</div>
						<div class="layui-form-item layui-form-text">
							<label class="layui-form-label">bgm音量</label>
							<div class="layui-input-block" id="bgmVolume" style="position: relative; top: 10px;">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">音效</label>
							<div class="layui-input-block">
								<select name="effect" lay-filter="effect">
									<option value="none">无</option>
									<option value="voice" checked>人声配音</option>
									<option value="stars">小星星钢琴曲</option>
									<option value="piano">纯音乐钢琴曲(deskgood作曲)</option>
									<option value="piano2">纯音乐钢琴曲2</option>
									<option value="LonelyWarrior">孤勇者</option>
									<option value="custom">自定义</option>
								</select>
							</div>
						</div>
						<div class="layui-form-item layui-form-text" style="display: none;">
							<label class="layui-form-label">音效乐谱</label>
							<div class="layui-input-block">
								<textarea name="effect_custom" rows="10" placeholder="请输入乐谱" class="layui-textarea"></textarea>
							</div>
						</div>
						<div class="layui-form-item layui-form-text">
							<label class="layui-form-label">音效音量</label>
							<div class="layui-input-block" id="effectVolume" style="position: relative; top: 10px;">
							</div>
						</div>
						<div class="layui-word-aux">提示：音乐设置会自动重启页面生效</div>
					</form>
					<form class="language layui-tab-item layui-form" onsubmit="return false;">
						<div class="layui-form-item">
							<label class="layui-form-label">语言(Language)</label>
							<div class="layui-input-block">
								<select name="language" lay-filter="language">
									<option value="zh-CN">Simplified Chinese (简体中文)</option>
									<option value="zh-TW">Traditional Chinese (繁体中文)</option>
									<option value="en-US">English (英语)</option>
								</select>
							</div>
						</div>
						<div class="layui-word-aux">提示：语言设置会自动重启页面生效</div>
					</form>
				</div>
			</div>
			<div class="btn">
				<button class="save">保存</button>
				<button class="cancel">取消</button>
			</div>
		</section>
		<section id="record" style="display: none;">
			<h2>战绩</h2>
			<h3>2D人机对战</h3>
			<table class="two" border="2">
				<tr><th>连子数</th><th>先手</th><th>棋盘大小</th><th style="color:red;">胜</th><th style="color:green;">负</th><th>总</th><th>胜率<br>(概率)</th></tr>
			</table>
			<h3>3D人机对战</h3>
			<table class="three" border="2">
				<tr><th>连子数</th><th>先手</th><th>棋盘大小</th><th style="color:red;">胜</th><th style="color:green;">负</th><th>总</th><th>胜率<br>(概率)</th></tr>
			</table>
			<h3>4D人机对战</h3>
			<table class="four" border="2">
				<tr><th>连子数</th><th>先手</th><th>棋盘大小</th><th style="color:red;">胜</th><th style="color:green;">负</th><th>总</th><th>胜率<br>(概率)</th></tr>
			</table>
			<button class="back">确定</button>
		</section>
		
<script>
let device;
if ( /ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/.test( navigator.userAgent.toLowerCase() ) ){
	device = 1; //手机
}else{
	device = 0; //电脑
}
document.addEventListener("plusready", function(){
	plus.navigator.setStatusBarBackground("#000");
	plus.navigator.setStatusBarStyle("light");
}, false);
</script>
<script>
$("html").addClass("fadeIn");
function go(url){
	layer.load(0);
	$("html").addClass("outUp");
	setTimeout(function(){
		if (typeof plus != "undefined"){
			plus.navigator.setStatusBarBackground("#aef");
			plus.navigator.setStatusBarStyle("dark");
		}
		location.href = url;
	}, 600);
}


$("button, input[type='button'], .layui-tab-title *, #set, #openRecord").click(function(){
	playEffect(); //播放音效
});
setTimeout(function(){
	$("input[type='radio'], input[type='checkbox'], .layer-form-switch").next().click(function(){
		playEffect(); //播放音效
	});
}, 1000);



const setting_game = JSON.parse(localStorage.getItem("五子棋_游戏设置") || "{}"),
	setting_personal = JSON.parse(localStorage.getItem("五子棋_个性化设置") || "{}"),
	setting_music = JSON.parse(localStorage.getItem("五子棋_音乐设置") || "{}"),
	game_record = JSON.parse(localStorage.getItem("五子棋_战绩") || "{}"),
	form_game = $("#settings form.game")[0],
	form_personal = $("#settings form.personal")[0],
	form_music = $("#settings form.music")[0];
	form_language = $("#settings form.language")[0];

let inputD = 2;
function setD(D){
	switch (D){
		case 2:
			inputD = 2;
			$(form_game).find("button.two")
				.removeClass("layui-btn-primary layui-border-green")
				.siblings().addClass("layui-btn-primary layui-border-green")
				.parent().parent().children(".text")
				.html("2D：回归传统，品味经典游戏");
			form_game.cols.init = form_game.rows.init = 19; //初始值为19
			form_game.cols.value = form_game.rows.value = 19; //值为19
			form_game.totalTime.init = 300; //初始值为300
			form_game.totalTime.value = 300; //值为300
			form_game.stepTime.init = 30; //初始值为30
			form_game.stepTime.value = 30; //值为30
			$(form_game.depth).parent().parent().hide("slow");
			$(form_game.width).parent().parent().hide("slow");
			$(form_game.place).parent().parent().show("slow");
			break;
			
		case 3:
			inputD = 3;
			$(form_game).find("button.three")
				.removeClass("layui-btn-primary layui-border-green")
				.siblings().addClass("layui-btn-primary layui-border-green")
				.parent().parent().children(".text")
				.html("3D：创意之作，体味烧脑乐趣");
			form_game.cols.init = form_game.rows.init = form_game.depth.init = 10; //初始值为10
			form_game.cols.value = form_game.rows.value = form_game.depth.value = 10; //值为10
			form_game.totalTime.init = 600; //初始值为600
			form_game.totalTime.value = 600; //值为600
			form_game.stepTime.init = 45; //初始值为45
			form_game.stepTime.value = 45; //值为45
			$(form_game.depth).parent().parent().show("slow");
			$(form_game.width).parent().parent().hide("slow");
			$(form_game.place).parent().parent().hide("slow");
			break;
			
		case 4:
			inputD = 4;
			$(form_game).find("button.four")
				.removeClass("layui-btn-primary layui-border-green")
				.siblings().addClass("layui-btn-primary layui-border-green")
				.parent().parent().children(".text")
				.html("4D：四维空间，挑战最强大脑");
			form_game.cols.init = form_game.rows.init = form_game.depth.init = form_game.width.init = 10; //初始值为10
			form_game.cols.value = form_game.rows.value = form_game.depth.value = form_game.width.value = 10; //值为10
			form_game.totalTime.init = 900; //初始值为900
			form_game.totalTime.value = 900; //值为900
			form_game.stepTime.init = 60; //初始值为60
			form_game.stepTime.value = 60; //值为60
			$(form_game.depth).parent().parent().show("slow");
			$(form_game.width).parent().parent().show("slow");
			$(form_game.place).parent().parent().hide("slow");
			break;
	}
}


//保存设置
function saveSetting(){
	localStorage.setItem("五子棋_游戏设置", JSON.stringify(setting_game));
	localStorage.setItem("五子棋_个性化设置", JSON.stringify(setting_personal));
	let needReload = localStorage.getItem("五子棋_音乐设置") != JSON.stringify(setting_music) ||
		localStorage.getItem("五子棋_语言") != LANG_TYPE; //改变则需要重启
	localStorage.setItem("五子棋_音乐设置", JSON.stringify(setting_music));
	localStorage.setItem("五子棋_语言", LANG_TYPE);
	if (needReload)
		if (typeof plus != "undefined"){
			plus.runtime.restart();
		}else{
			location.reload();
		}
}

//加载设置
let bgmVolumeSliderValue, effectVolumeSliderValue; //音量拖动条的值
function readSetting(){
	//初始化设置
	setting_game.D = setting_game.D || 2;
	setting_game.N = setting_game.N || 5;
	setting_game.cols = setting_game.cols || 19;
	setting_game.rows = setting_game.rows || 19;
	setting_game.depth = setting_game.depth || 10;
	setting_game.width = setting_game.width || 10;
	setting_game.place = setting_game.place || 0;
	setting_game.totalTime = setting_game.totalTime || 300;
	setting_game.stepTime = setting_game.stepTime || 30;
	
	setting_personal.skybox = OR(setting_personal.skybox, true);
	setting_personal.moon = OR(setting_personal.moon, true);
	setting_personal.border = OR(setting_personal.border, true);
	
	setting_music.bgm = setting_music.bgm || "piano";
	setting_music.bgmVolume = OR(setting_music.bgmVolume, 100);
	setting_music.effect = setting_music.effect || "voice";
	setting_music.effectVolume = OR(setting_music.effectVolume, 100);
	
	
	//游戏设置
	setD(setting_game.D);
	form_game.n.value = setting_game.N;
	form_game.cols.value = setting_game.cols;
	form_game.rows.value = setting_game.rows;
	form_game.depth.value = setting_game.depth;
	form_game.width.value = setting_game.width;
	form_game.place[+setting_game.place].checked = true;
	form_game.totalTime.value = setting_game.totalTime;
	form_game.stepTime.value = setting_game.stepTime;
	
	//个性化设置
	if ( setting_personal.mistake !== undefined ){ //有设置
		$(form_personal).find("input.mistake")[0].checked = !!setting_personal.mistake;
	}else{ //无设置 自动
		if (device){ //手机
			setting_personal.mistake = true;
		}else{ //电脑
			setting_personal.mistake = false;
		}
		$(form_personal).find("input.mistake")[0].checked = setting_personal.mistake;
	}
	$(form_personal).find("input.skybox")[0].checked = setting_personal.skybox;
	$(form_personal).find("input.moon")[0].checked = setting_personal.moon;
	$(form_personal).find("input.border")[0].checked = setting_personal.border;
	
	//音乐设置
	form_music.bgm_custom.value = MUSICS.piano; //默认：deskgood作曲钢琴曲
	form_music.effect_custom.value = MUSICS.stars; //默认：小星星
	if (setting_music.bgm == "local"){ //本地文件
		form_music.bgm.value = "local";
		$(form_music.bgm_local).parent().parent().show();
		$(form_music.bgm_custom).parent().parent().hide();
	}else if (["none", "piano", "piano2", "youth", "LonelyWarrior", "random"].indexOf(setting_music.bgm) == -1){ //自定义
		form_music.bgm.value = "custom";
		$(form_music.bgm_local).parent().parent().hide();
		form_music.bgm_custom.value = setting_music.bgm;
		$(form_music.bgm_custom).parent().parent().show();
	}else{ //内置音乐
		form_music.bgm.value = setting_music.bgm;
		$(form_music.bgm_local).parent().parent().hide();
		$(form_music.bgm_custom).parent().parent().hide();
	}
	if (["none", "voice", "stars", "piano", "piano2", "LonelyWarrior"].indexOf(setting_music.effect) == -1){ //自定义
		form_music.effect.value = "custom";
		form_music.effect_custom.value = setting_music.effect;
		$(form_music.effect_custom).parent().parent().show();
	}else{
		form_music.effect.value = setting_music.effect;
		$(form_music.effect_custom).parent().parent().hide();
	}
	
	//滑块
	layui.use("slider", function(){
		const slider = layui.slider;
		
		//渲染
		bgmVolumeSliderValue = setting_music.bgmVolume;
		slider.render({
			elem: "#bgmVolume",
			min: 0,
			max: 100,
			value: setting_music.bgmVolume,
			input: true,
			tips: true,
			setTips(value){
				return value + "%";
			},
			change(value){
				bgmVolumeSliderValue = value;
			}
		});
		
		effectVolumeSliderValue = setting_music.effectVolume;
		slider.render({
			elem: "#effectVolume",
			min: 0,
			max: 100,
			value: setting_music.effectVolume,
			input: true,
			tips: true,
			setTips(value){
				return value + "%";
			},
			change(value){
				effectVolumeSliderValue = value;
			}
		});
	});
	
	//语言设置
	form_language.language.value = LANG_TYPE;
	
	//更新显示
	layui.use("form", function(){
		const form = layui.form;
		form.render(); //重绘
	});
	
	saveSetting(); //保存设置
}
readSetting();

//加载战绩
function readRecord(){
	//2D
	game_record.two = game_record.two || {};
	game_record.two.win = game_record.two.win || 0;
	game_record.two.fail = game_record.two.fail || 0;
	game_record.two.total = game_record.two.total || 0;
	//3D
	game_record.three = game_record.three || {};
	game_record.three.win = game_record.three.win || 0;
	game_record.three.fail = game_record.three.fail || 0;
	game_record.three.total = game_record.three.total || 0;
	//4D
	game_record.four = game_record.four || {};
	game_record.four.win = game_record.four.win || 0;
	game_record.four.fail = game_record.four.fail || 0;
	game_record.four.total = game_record.four.total || 0;
	
	$("#record > table tr:not(:first-child)").remove(); //先清空
	
	//2D
	for (const N in game_record.two){
		if ( isNaN(N) ) continue; //非数字
		
		let firstN = true;
		for (const first in game_record.two[N]){
			if ( isNaN(first) ) continue; //非数字
			
			let firstFirst = true;
			for (const size in game_record.two[N][first]){
				if (size.indexOf("*") == -1) continue; //不含*
				
				$("#record > table.two").append(
					$("<tr></tr>").append(
						firstN
						?$(`<td rowspan="${Object.keys(game_record.two[N][0]).length-3+1+Object.keys(game_record.two[N][1]).length-3+1+1}">${N}</td>`)
							.css("border-top-width", "4px")
						:null
					).append(
						firstFirst
						?$(`<td rowspan="${Object.keys(game_record.two[N][first]).length-3+1}">${+first? "先手": "后手"}</td>`)
							.css("border-top-width", firstN? "4px": "2px")
						:null
					).append(
						$("<td></td>").html(size)
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(game_record.two[N][first][size].win)
							.css("color", "red")
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(game_record.two[N][first][size].fail)
							.css("color", "green")
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(game_record.two[N][first][size].total)
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(Math.round(game_record.two[N][first][size].win / game_record.two[N][first][size].total*100, 2) + "%")
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					)
				);
				firstN = false;
				firstFirst = false;
			}
			$("#record > table.two").append(
				$("<tr></tr>").append(
					$("<td></td>").html("总计")
				).append(
					$("<td></td>").html(game_record.two[N][first].win)
						.css("color", "red")
				).append(
					$("<td></td>").html(game_record.two[N][first].fail)
						.css("color", "green")
				).append(
					$("<td></td>").html(game_record.two[N][first].total)
				).append(
					$("<td></td>").html(Math.round(game_record.two[N][first].win / game_record.two[N][first].total*100, 2) + "%")
				)
			);
		}
		$("#record > table.two").append(
			$("<tr></tr>").append(
				$("<td colspan='2'></td>").html("总计")
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(game_record.two[N].win)
					.css("color", "red")
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(game_record.two[N].fail)
					.css("color", "green")
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(game_record.two[N].total)
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(Math.round(game_record.two[N].win / game_record.two[N].total*100, 2) + "%")
					.css("border-top-width", "2px")
			)
		);
	}
	$("#record > table.two").append(
		$("<tr></tr>").append(
			$("<td colspan='3'></td>").html("总计")
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(game_record.two.win)
				.css("color", "red")
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(game_record.two.fail)
				.css("color", "green")
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(game_record.two.total)
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(Math.round(game_record.two.win / game_record.two.total*100, 2) + "%<br>(" + Math.round((game_record.two.win+1) / (game_record.two.total+2)*100, 2) + "%)")
				.css("border-top-width", "4px")
				.css("font-weight", "bold")
		)
	);
	
	//3D
	for (const N in game_record.three){
		if ( isNaN(N) ) continue; //非数字
		
		let firstN = true;
		for (const first in game_record.three[N]){
			if ( isNaN(first) ) continue; //非数字
			
			let firstFirst = true;
			for (const size in game_record.three[N][first]){
				if (size.indexOf("*") == -1) continue; //不含*
				
				$("#record > table.three").append(
					$("<tr></tr>").append(
						firstN
						?$(`<td rowspan="${Object.keys(game_record.three[N][0]).length-3+1+Object.keys(game_record.three[N][1]).length-3+1+1}">${N}</td>`)
							.css("border-top-width", "4px")
						:null
					).append(
						firstFirst
						?$(`<td rowspan="${Object.keys(game_record.three[N][first]).length-3+1}">${+first? "先手": "后手"}</td>`)
							.css("border-top-width", firstN? "4px": "2px")
						:null
					).append(
						$("<td></td>").html(size)
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(game_record.three[N][first][size].win)
							.css("color", "red")
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(game_record.three[N][first][size].fail)
							.css("color", "green")
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(game_record.three[N][first][size].total)
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(Math.round(game_record.three[N][first][size].win / game_record.three[N][first][size].total*100, 2) + "%")
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					)
				);
				firstN = false;
				firstFirst = false;
			}
			$("#record > table.three").append(
				$("<tr></tr>").append(
					$("<td></td>").html("总计")
				).append(
					$("<td></td>").html(game_record.three[N][first].win)
					.css("color", "red")
				).append(
					$("<td></td>").html(game_record.three[N][first].fail)
					.css("color", "green")
				).append(
					$("<td></td>").html(game_record.three[N][first].total)
				).append(
					$("<td></td>").html(Math.round(game_record.three[N][first].win / game_record.three[N][first].total*100, 2) + "%")
				)
			);
		}
		$("#record > table.three").append(
			$("<tr></tr>").append(
				$("<td colspan='2'></td>").html("总计")
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(game_record.three[N].win)
					.css("color", "red")
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(game_record.three[N].fail)
					.css("color", "green")
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(game_record.three[N].total)
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(Math.round(game_record.three[N].win / game_record.three[N].total*100, 2) + "%")
					.css("border-top-width", "2px")
			)
		);
	}
	$("#record > table.three").append(
		$("<tr></tr>").append(
			$("<td colspan='3'></td>").html("总计")
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(game_record.three.win)
				.css("color", "red")
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(game_record.three.fail)
				.css("color", "green")
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(game_record.three.total)
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(Math.round(game_record.three.win / game_record.three.total*100, 2) + "%<br>(" + Math.round((game_record.three.win+1) / (game_record.three.total+2)*100, 2) + "%)")
				.css("border-top-width", "4px")
				.css("font-weight", "bold")
		)
	);
	
	//4D
	for (const N in game_record.four){
		if ( isNaN(N) ) continue; //非数字
		
		let firstN = true;
		for (const first in game_record.four[N]){
			if ( isNaN(first) ) continue; //非数字
			
			let firstFirst = true;
			for (const size in game_record.four[N][first]){
				if (size.indexOf("*") == -1) continue; //不含*
				
				$("#record > table.four").append(
					$("<tr></tr>").append(
						firstN
						?$(`<td rowspan="${Object.keys(game_record.four[N][0]).length-3+1+Object.keys(game_record.four[N][1]).length-3+1+1}">${N}</td>`)
							.css("border-top-width", "4px")
						:null
					).append(
						firstFirst
						?$(`<td rowspan="${Object.keys(game_record.four[N][first]).length-3+1}">${+first? "先手": "后手"}</td>`)
							.css("border-top-width", firstN? "4px": "2px")
						:null
					).append(
						$("<td></td>").html(size)
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(game_record.four[N][first][size].win)
							.css("color", "red")
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(game_record.four[N][first][size].fail)
							.css("color", "green")
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(game_record.four[N][first][size].total)
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					).append(
						$("<td></td>").html(Math.round(game_record.four[N][first][size].win / game_record.four[N][first][size].total*100, 2) + "%")
							.css("border-top-width", firstN? "4px": firstFirst? "2px": "1px")
					)
				);
				firstN = false;
				firstFirst = false;
			}
			$("#record > table.four").append(
				$("<tr></tr>").append(
					$("<td></td>").html("总计")
				).append(
					$("<td></td>").html(game_record.four[N][first].win)
						.css("color", "red")
				).append(
					$("<td></td>").html(game_record.four[N][first].fail)
						.css("color", "green")
				).append(
					$("<td></td>").html(game_record.four[N][first].total)
				).append(
					$("<td></td>").html(Math.round(game_record.four[N][first].win / game_record.four[N][first].total*100, 2) + "%")
				)
			);
		}
		$("#record > table.four").append(
			$("<tr></tr>").append(
				$("<td colspan='2'></td>").html("总计")
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(game_record.four[N].win)
					.css("color", "red")
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(game_record.four[N].fail)
					.css("color", "green")
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(game_record.four[N].total)
					.css("border-top-width", "2px")
			).append(
				$("<td></td>").html(Math.round(game_record.four[N].win / game_record.four[N].total*100, 2) + "%")
					.css("border-top-width", "2px")
			)
		);
	}
	$("#record > table.four").append(
		$("<tr></tr>").append(
			$("<td colspan='3'></td>").html("总计")
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(game_record.four.win)
				.css("color", "red")
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(game_record.four.fail)
				.css("color", "green")
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(game_record.four.total)
				.css("border-top-width", "4px")
		).append(
			$("<td></td>").html(Math.round(game_record.four.win / game_record.four.total*100, 2) + "%<br>(" + Math.round((game_record.four.win+1) / (game_record.four.total+2)*100, 2) + "%)")
				.css("border-top-width", "4px")
				.css("font-weight", "bold")
		)
	);
}


//维数切换
$(form_game).find("button.two").click(function(){
	setD(2);
});
$(form_game).find("button.three").click(function(){
	setD(3);
});
$(form_game).find("button.four").click(function(){
	setD(4);
});

let bgmTest, //bgm测试
	effectTest; //音效测试
layui.use("form", function(){
	const form = layui.form;
	//天空盒 影响 月亮
	form.on("switch(skybox)", function(data){
		console.log(data)
		if (data.elem.checked){
			$(form_personal).find("input.moon").parent().parent().show("slow");
		}else{
			$(form_personal).find("input.moon").parent().parent().hide("slow");
		}
	});
	
	//背景音乐自定义
	form.on("select(bgm)", function(data){
		console.log("bgm change", data.value)
		if (data.value == "local"){
			$(form_music.bgm_local).parent().parent().show("slow");
		}else{
			$(form_music.bgm_local).parent().parent().hide("slow");
		}
		if (data.value == "custom"){
			$(form_music.bgm_custom).parent().parent().show("slow");
		}else{
			$(form_music.bgm_custom).parent().parent().hide("slow");
		}
		if (data.value == "piano"){ //测试播放
			if (!bgm) //未播放bgm
				bgmTest = new Music(MUSICS.piano, 6, 72).play();
		}else if (data.value == "piano2"){ //测试播放
			if (!bgm)
				bgmTest = new Music(MUSICS.piano2, 6, 72).play();
		}else if (data.value == "youth"){ //测试播放
			if (!bgm)
				bgmTest = new Player("./music/piano.mp3");
		}else if (data.value == "LonelyWarrior"){ //测试播放
			if (!bgm)
				bgmTest = new Music(MUSICS.LonelyWarrior, 6, 72).play();
		}else if (data.value == "random"){ //测试播放
			if (!bgm)
				bgmTest = new Player("https://api.vvhan.com/api/rand.music?sort=热歌榜");
		}else if (data.value == "none"){ //无 停止播放
			if (bgmTest){ //停止bgm测试
				if (bgmTest.stop) bgmTest.stop();
				if (bgmTest.setStop) bgmTest.setStop(true);
			}
		}
	});
	//音效自定义
	form.on("select(effect)", function(data){
		console.log("effect change", data.value)
		if (data.value == "custom"){
			$(form_music.effect_custom).parent().parent().show("slow");
		}else{
			$(form_music.effect_custom).parent().parent().hide("slow");
		}
		if (data.value == "voice"){ //测试播放
			if (effectTest){ //停止音效测试
				if (effectTest.stop) effectTest.stop();
				if (effectTest.setStop) effectTest.setStop(true);
			}
			effectTest = new Player("./music/effect.m4a", false, 0.8).play();
		}else if (data.value == "stars"){ //测试播放
			if (effectTest){ //停止音效测试
				if (effectTest.stop) effectTest.stop();
				if (effectTest.setStop) effectTest.setStop(true);
			}
			effectTest = new Music(MUSICS.stars, 6, 72).play();
		}else if (data.value == "piano"){ //测试播放
			if (effectTest){ //停止音效测试
				if (effectTest.stop) effectTest.stop();
				if (effectTest.setStop) effectTest.setStop(true);
			}
			effectTest = new Music(MUSICS.piano, 6, 72).play();
		}else if (data.value == "piano2"){ //测试播放
			if (effectTest){ //停止音效测试
				if (effectTest.stop) effectTest.stop();
				if (effectTest.setStop) effectTest.setStop(true);
			}
			effectTest = new Music(MUSICS.piano2, 6, 72).play();
		}else if (data.value == "LonelyWarrior"){ //测试播放
			if (effectTest){ //停止音效测试
				if (effectTest.stop) effectTest.stop();
				if (effectTest.setStop) effectTest.setStop(true);
			}
			effectTest = new Music(MUSICS.LonelyWarrior, 6, 72).play();
		}else if (data.value == "none"){ //无 停止播放
			if (effectTest){ //停止音效测试
				if (effectTest.stop) effectTest.stop();
				if (effectTest.setStop) effectTest.setStop(true);
			}
		}
	});
});

//本地bgm改变 测试播放
$(form_music.bgm_local).change(async function(file){
	console.log("bgm local change")
	const url = await URL.blob2base64(file.target.files[0]);
	if (!bgm)
		bgmTest = new Player(url).play();
	//存储为临时音频
	if (typeof plus != "undefined"){
		plus.storage.setItem("_本地音频", url);
		layer.msg("存储成功");
	}else{
		document.addEventListener("plusready", function(){
			plus.storage.setItem("_本地音频", url);
			layer.msg("存储成功");
		}, false);
	}
});

//自定义bgm改变 测试播放
$(form_music.bgm_custom).change(function(){
	console.log("bgm custom change")
	if (!bgm)
		bgmTest = new Music(form_music.bgm_custom.value, 6, 72).play();
});

//自定义音效改变 测试播放
$(form_music.effect_custom).change(function(){
	console.log("effect custom change")
	if (effectTest){
		if (effectTest.stop) effectTest.stop();
		if (effectTest.setStop) effectTest.setStop(true);
	}
	effectTest = new Music(form_music.effect_custom.value, 6, 72).play();
});


//输入改变
$("#settings form input[type='number']").change(function(){
	if (this.value == "")
		return (this.value = this.init); //初始值
	this.value = Math.limitRange(+this.value, +this.min, +this.max);
});



//双人对战
$("#two").click(function(){
	switch (setting_game.D){
		case 2:
			go("two_2D.html");
			break;
		case 3:
			go("two_3D.html");
			break;
		case 4:
			go("two_4D.html");
			break;
	}
});

//人机对战
$("#one").click(function(){
	switch (setting_game.D){
		case 2:
			go("one_2D.html");
			break;
		case 3:
			go("one_3D.html");
			break;
		case 4:
			go("one_4D.html");
			break;
	}
});

//多人联机
$("#online").click(function(){
	layer.msg("抱歉，此功能暂不开放");
});

$("#tutorial").click(function(){
	go("https://www.taptap.com/moment/180362832993321673");
});


//打开设置
$("#set").click(function(){
	readSetting(); //读取设置
	$("#settings").slideDown("slow");
});

//取消
$("#settings button.cancel").click(function(){
	if (effectTest){ //停止音效测试
		if (effectTest.stop) effectTest.stop();
		if (effectTest.setStop) effectTest.setStop(true);
	}
	$("#settings").slideUp("slow");
});

//保存
$("#settings button.save").click(function(){
	if (effectTest){ //停止音效测试
		if (effectTest.stop) effectTest.stop();
		if (effectTest.setStop) effectTest.setStop(true);
	}
	
	setting_game.D = inputD;
	setting_game.N = +form_game.n.value;
	setting_game.cols = +form_game.cols.value;
	setting_game.rows = +form_game.rows.value;
	setting_game.depth = +form_game.depth.value;
	setting_game.width = +form_game.width.value;
	setting_game.place = +form_game.place[1].checked;
	setting_game.totalTime = +form_game.totalTime.value;
	setting_game.stepTime = +form_game.stepTime.value;
	
	setting_personal.mistake = form_personal.mistake.checked;
	setting_personal.skybox = form_personal.skybox.checked;
	setting_personal.moon = form_personal.moon.checked;
	setting_personal.border = form_personal.border.checked;
	
	if (form_music.bgm.value == "local"){ //设置音频
		if (typeof plus != "undefined"){
			plus.storage.setItem("本地音频", plus.storage.getItem("_本地音频"));
		}else{
			document.addEventListener("plusready", function(){
				plus.storage.setItem("本地音频", plus.storage.getItem("_本地音频"));
			}, false);
		}
	}else{ //删除音频
		if (typeof plus != "undefined"){
			plus.storage.removeItem("本地音频");
		}else{
			document.addEventListener("plusready", function(){
				plus.storage.removeItem("本地音频");
			}, false);
		}
	}
	if (form_music.bgm.value == "custom"){
		setting_music.bgm = form_music.bgm_custom.value
	}else{
		setting_music.bgm = form_music.bgm.value;
	}
	if (form_music.effect.value == "custom"){
		setting_music.effect = form_music.effect_custom.value
	}else{
		setting_music.effect = form_music.effect.value;
	}
	setting_music.bgmVolume = bgmVolumeSliderValue;
	setting_music.effectVolume = effectVolumeSliderValue;
	
	//删除临时音频
	if (typeof plus != "undefined"){
		plus.storage.removeItem("_本地音频");
	}else{
		document.addEventListener("plusready", function(){
			plus.storage.removeItem("_本地音频");
		}, false);
	}
	
	LANG_TYPE = form_language.language.value;
	
	saveSetting();
	layer.msg("设置成功");
	$("#settings").slideUp("slow");
});

//打开战绩
$("#openRecord").click(function(){
	readRecord(); //读取战绩
	$("#record").slideDown("slow");
});

//返回
$("#record > .back").click(function(){
	$("#record").slideUp("slow");
});



//双击
$("body > h1").on("dblclick",function(){
	const num = Math.random(36, 72);
	for (let i=0; i<num; i++){
		$("body").animate({
			left: Math.random(-3, 3)+"%",
			top: Math.random(-3, 3)+"%",
			opacity: 1
		},10);
	}
	$("body").animate({
		left: "0%",
		top: "0%",
		opacity: 1
	},10);
});
</script>
		
	</body>
</html>
